Skip to content

feat!: default dotfiles to 'ignore' - #620

Open
mcollina wants to merge 2 commits into
mainfrom
feat/dotfiles-ignore-default
Open

mcollina wants to merge 2 commits into
mainfrom
feat/dotfiles-ignore-default

Conversation

@mcollina

Copy link
Copy Markdown
Member

Change the default of the dotfiles option from 'allow' to 'ignore'.

This aligns @fastify/static with the defaults of @fastify/send and serve-static. Dotfiles — and files inside hidden directories, such as /.well-known/... — are no longer served unless you opt in with dotfiles: 'allow'. Sensitive dotfiles like .env, .htpasswd or .git/config that may be present in the static root are no longer exposed by default.

This is a breaking change:

  • The default dotfiles value is now 'ignore'.
  • Requests for dotfiles or files under a hidden directory return 404 unless dotfiles: 'allow' is set.
  • If you rely on serving /.well-known/... (for example ACME or PGP discovery) or other dot-prefixed paths, set dotfiles: 'allow' explicitly.

Also updates the README to document the new default and the behaviour change, bumps the version to 11.0.0, and updates the affected tests.

Change the default for the `dotfiles` option from `'allow'` to `'ignore'`,
matching the `@fastify/send` and `serve-static` defaults. Dotfiles and files
inside hidden directories (for example `/.well-known/...`) are no longer served
unless `dotfiles: 'allow'` is set explicitly. This protects sensitive dotfiles
such as `.env`, `.htpasswd` and `.git/config` that may be left in the static
root.

Breaking change; bump the major version to 11.0.0.
@gurgunday gurgunday added the semver-major Issue or PR that should land as semver major label Oct 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-major Issue or PR that should land as semver major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants